// Dlg_Filter.cpp : implementation file
//

#include "stdafx.h"
#include "jjcap.h"
#include "Dlg_Filter.h"

#include "JjcapData.h"

extern CJjcapData CapData;

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDlg_Filter dialog


CDlg_Filter::CDlg_Filter(CWnd* pParent /*=NULL*/)
	: CDialog(CDlg_Filter::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDlg_Filter)
	m_exp = _T("");
	//}}AFX_DATA_INIT
}


void CDlg_Filter::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDlg_Filter)
	DDX_Text(pDX, IDC_EDIT_FILTER_EXP, m_exp);
	DDV_MaxChars(pDX, m_exp, 256);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDlg_Filter, CDialog)
	//{{AFX_MSG_MAP(CDlg_Filter)
	ON_BN_CLICKED(IDC_BTN_FILTER_CANCEL, OnBtnFilterCancel)
	ON_BN_CLICKED(IDC_BTN_FILTER_SAVE, OnBtnFilterSave)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDlg_Filter message handlers

BOOL CDlg_Filter::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	HICON hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
	SetIcon(hIcon, TRUE);
	SetIcon(hIcon, FALSE);
	
	m_exp = CapData.filter_exp;

	UpdateData(FALSE);

	GetDlgItem(IDC_EDIT_FILTER_EXP)->SetFocus();
	return FALSE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CDlg_Filter::OnBtnFilterCancel() 
{
	// TODO: Add your control notification handler code here
	CDialog::OnCancel();
}

void CDlg_Filter::OnBtnFilterSave() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	CapData.filter_exp = m_exp;
	CDialog::OnOK();
}

BOOL CDlg_Filter::PreTranslateMessage(MSG* pMsg) 
{
	// TODO: Add your specialized code here and/or call the base class
	if (pMsg->message == WM_KEYDOWN)
	{
		if (pMsg->wParam == VK_RETURN)
		{
			OnBtnFilterSave();
			return TRUE;
		}
	}
	return CDialog::PreTranslateMessage(pMsg);
}
